package cn.zktr.Personnel.controllers.zhouyongcong.end;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.zktr.Personnel.common.Md5Encode;
import cn.zktr.Personnel.model.pojos.PerPmsAct;
import cn.zktr.Personnel.model.pojos.PerPmsLxfs;
import cn.zktr.Personnel.model.service.zhouyongcong.boolService;
import cn.zktr.Personnel.model.service.zhouyongcong.findService;
import cn.zktr.Personnel.model.service.zhouyongcong.savePojosService;
import cn.zktr.Personnel.model.service.zhouyongcong.end.individualService;

@Controller
public class individualController {
	@Autowired
	private findService fs;
	@Autowired
	private individualService is;
	@Autowired
	private boolService bl;
	@Autowired
	private savePojosService sps;
	
	
	
	@RequestMapping("zyc/emp-individual")
	public void emp_individual(Model mod,HttpSession session) {
		Integer empid = Integer.valueOf(session.getAttribute("id")+"");
		mod.addAttribute("empdet", fs.findEmpid(empid));
	}
	@RequestMapping("zyc/emp-det")
	public void emp_det(Model mod,Integer id) {
		mod.addAttribute("empdet", fs.findEmpid(id));
	}
	@RequestMapping("zyc/emp-indpwd")
	public void emp_indpwd() {}
	
	@RequestMapping("zyc/emp-indheto")
	public void emp_indheto(Model mod,HttpSession session) {
		Integer empid = Integer.valueOf(session.getAttribute("id")+"");
		mod.addAttribute("empdet", fs.findEmpid(empid));
	}
	
	@RequestMapping("indivfind")
	@ResponseBody
	public void indivfind(HttpSession session,String text,String zd) {
		Integer empid = Integer.valueOf(session.getAttribute("id")+"");
		System.out.println(text+zd);
		is.indivfind(empid, text, zd);
	}
	@RequestMapping("indivfind_lxfs")
	@ResponseBody
	public List<PerPmsLxfs> indivfind_lxfs() {
		return is.indivfind_lxfs();
	}
	@RequestMapping("indivfind_addlx")
	@ResponseBody
	public void indivfind_addlx(HttpSession session,String lxfs,String lxxx,Integer lxxxid) {
		Integer empid = Integer.valueOf(session.getAttribute("id")+"");
		is.indivfind_addlx(empid,lxfs, lxxx,lxxxid);
	}
	
	@RequestMapping("indact")
	@ResponseBody
	public int indact(HttpSession session,String oldpwd) {
		Integer empid = Integer.valueOf(session.getAttribute("id")+"");
		return bl.bool_Act(fs.findEmpid(empid), new Md5Encode().MD5Encode(oldpwd));
	}
	
	@RequestMapping("indact_true")
	@ResponseBody
	public void indact_true(HttpSession session,String newpwd) {
		Integer empid = Integer.valueOf(session.getAttribute("id")+"");
		PerPmsAct ppa = fs.findEmpid(empid).getPerPmsActs().get(0);
		ppa.setActpwds(ppa.getActpwd());
		ppa.setActpwd(new Md5Encode().MD5Encode(newpwd));
		sps.modif_Act(ppa);
	}
	
}
